import { Controller, Get } from '@nestjs/common';
import { UserService } from './modules/user/user.service';
import { User } from './modules/user/models/user.entity';
import { Result } from './common/dto/result.type';

@Controller()
export class AppController {
  constructor(private readonly userService: UserService) {}
  @Get('/create')
  async create(): Promise<boolean> {
    return await this.userService.create({
      name: '水滴管理员4',
      desc: '管理员4',
      tel: '2131212',
      password: '4444',
      account: 'admin',
    });
  }
  @Get('/del')
  async del(): Promise<boolean> {
    return await this.userService.del('58a2ec54-6780-4710-9191-5785373d5069');
  }
  @Get('/update')
  async update(): Promise<Result> {
    return await this.userService.update(
      '1a77c82f-9fe4-4ecd-8c78-8cf309fda8f0',
      {
        name: '修改水滴管理员4',
        desc: '修改管理员4',
        tel: '66666',
        password: '666',
        account: 'test1',
      },
    );
  }
  @Get('/find')
  async find(): Promise<User> {
    return await this.userService.find('1a77c82f-9fe4-4ecd-8c78-8cf309fda8f0');
  }
}
